/*
 * Copyright (c) 2022 上海市政工程设计研究总院(集团)有限公司 All Rights Reserved.
 */
package com.smedi.ismedi.constructionproject.core.application.convert;


import com.smedi.ismedi.constructionproject.core.application.command.*;
import com.smedi.ismedi.constructionproject.core.domain.aggregatemodel.*;
import org.mapstruct.*;

import java.util.List;

/**
 * application Converter
 *
 * @author 15428
 * &#064;date  2022-06-07 15:22:03
 * @since 0.0.1
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface AppConverter {
    @Mapping(source = "fileKeys", target = "files", qualifiedByName = "keyToFile")
    @Mapping(source = "applyPersonId", target = "applyPerson.id")
    @Mapping(source = "projectId", target = "project.projectId")
    ProjectApply projectApplyCreateCommandToProjectAppy(ProjectApplyCreateCommand projectApplyCreateCommand);

    @Mapping(source = "fileKeys", target = "files", qualifiedByName = "keyToFile")
    ProjectApply projectApplyEditCommandToProjectAppy(ProjectApplyEditCommand projectApplyEditCommand);

    @Mapping(source = "fileKeys", target = "files", qualifiedByName = "keyToFile")
    @Mapping(source = "applyPersonId", target = "applyPerson.id")
    @Mapping(source = "projectId", target = "project.projectId")
    ProjectApply projectApplyEditCommandProjectApply(ProjectApplyEditCommand projectApplyEditCommand);

    ProjectApplyCreateCommand projectApplyEditCommandToCreateCommand(ProjectApplyEditCommand projectApplyEditCommand);

    @Mapping(source = "fileKeys", target = "files", qualifiedByName = "keyToFile")
    ProjectApply updateProjectApply(@MappingTarget ProjectApply projectApply, ProjectApplyEditCommand projectApplyEditCommand);

    @Mapping(target = "signKeys")
    @Named("keyToFile")
    List<File> keyToAttachment(List<String> signKeys);

    @Mapping(target = "signKey")
    File keyToAttachment(String signKey);

    @Mapping(target = "projectId")
    ProjectBasic projectIdToProjectBasic(Long projectId);

    @Mapping(source = "applyPersonId", target = "id")
    Person applyPersonIdToPerson(Long applyPersonId);

    ProjectApplyQuery projectApplyOneQueryToQuery(ProjectApplyOneQuery projectApplyOneQuery);

    ProjectApplyQuery projectApplyListQueryToQuery(ProjectApplyListQuery projectApplyListQuery);

    ProjectApplyQuery projectApplyPageQueryToQuery(ProjectApplyPageQuery projectApplyPageQuery);

    ProjectBasic updateProjectBasicByProjectBasicUpdateCommand(@MappingTarget ProjectBasic projectBasic, ProjectBasicUpdateCommand projectBasicUpdateCommand);
}
